;(function(root, factory){
	if (typeof exports === "object") {
        // CommonJS
        module.exports = exports = factory();
    }
    else if (typeof define === "function" && define.amd) {
        // AMD
        define([], factory);
    }
    else {
        // Global (browser)
        if (!root.window) {
        	root.StringReader = factory();
        }
    }
})(this, function(){
	function StringReader(buffer){
		let index = 0;
		let length = buffer.length;
		let strReader = {};
		strReader.read = function(){
			if(index > length){
				return -1;
			}
			return buffer.charAt(index++);
		}
		strReader.whenRead = function(ch){
			let rst = "";
			let c = -1;
			while( -1 != (c = strReader.read()) ){
				if (c == ch) {
					break;
				}
				rst += c;
			}
			if (c == -1 && rst === "") {
				return null;
			}
			return rst;
		}
		strReader.readLine = function(){
			return strReader.whenRead('\n');
		}
		return strReader;
	}
	StringReader.test = function(){
		console.log("test-123");
	}
	return StringReader;
})